const user =require('../../model/User/index')
module.exports={
    getUserList:(req,res,next)=>{
        user.getUserList().then(result=>{
            req.userList=result
            next()
        }).catch(err=>{
            next(err)
        })
    },
    addUser:(req,res,next)=>{
        let {age,birthday,type,name,icon}=req.body
        user.addUser(age,birthday,type,name,icon).then(result=>{
            req.insertId=result
            next()
        }).catch(err=>{
            next(err)
        })
    },
    checkUsername:(req,res,next)=>{
        let {username}=req.body
        user.checkUsername(username).then(result=>{
            req.checkResult=result[0]
            next()
        }).catch(err=>{
            next(err)
        })
    },
    login:(req,res,next)=>{
        let {username,password}=req.body
        user.login(username,password).then(result=>{
            req.loginResult=result[0]
            next()
        }).catch(err=>{
            next(err)
        })
    },
}